#include<bits/stdc++.h>
#define int long long
#define ls(x) ((x)*2)
#define rs(x) ((x)*2+1)
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define For(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define Rof(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define rep(i,  b) for(int i=1,i##end=b;i<=i##end;i++)
using namespace std;
const int N=1e6+5,base=999983,Mod=998244353;
char buf[(1<<21)+5],*p1,*p2;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline void chmx(int &x,int y){(x<y)&&(x=y);}
inline void chmn(int &x,int y){(x>y)&&(x=y);}
inline void Add(int &x,int y){(x=x+y+Mod)%=Mod;}
inline int read(){
	int f=0,x=0;
	char ch=getchar();
	while(!isdigit(ch)){f|=(ch=='-');ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?-x:x;
}
void print(int n){
    if(n<0){
        putchar('-');
        n*=-1;
    }
    if(n>9) print(n/10);
    putchar(n%10+'0');
}
int n,k,D;
int h[N],t[N];
multiset<int>e[N];
set<pair<int,int> >S;
int cnt[N];
int f[N],val[N],p,id[N];
vector<int>q[N];
signed main(){
	freopen("holiday.in","r",stdin);
	freopen("holiday.out","w",stdout);
	// ios::sync_with_stdio(false);
	// cin.tie(0); cout.tie(0);
	n=read(),k=read(),D=read();
	For(i,1,n) h[i]=read();
	For(i,1,n-1) t[i]=read();
	if(n<=5000){
		memset(f,-0x3f,sizeof(f));
		f[1]=0;
		For(i,1,n){
			f[i]+=h[i];
			For(j,i+1,i+t[i]){
				f[j]=max(f[j],f[i]-(j-i)/k*D);
			}
		}
		printf("%lld\n",f[n]);
		return 0;
	}
	f[1]=h[1];cnt[1%k]++;
	e[1%k].insert(f[1]+cnt[1%k]*D);
	val[1]=cnt[1%k];
	q[1+t[1]+1].emplace_back(1);
	S.insert({f[1],1%k});
	For(i,0,k-1) e[i].insert(-1e18);
	int u;
	For(i,2,n){
		for(auto v:q[i]){
			u=v%k;
			if(f[v]+val[v]*D!=(*e[u].rbegin())){
				e[u].erase(f[v]+val[v]*D);
				continue;
			}
			S.erase({f[v]+val[v]*D-cnt[u]*D,u});
			e[u].erase(f[v]+val[v]*D);
//			S.insert({(*e[u].rbegin())-cnt[u]*D,u}); 
		}
		u=i%k;
//		S.erase({(*e[u].rbegin())-cnt[u]*D,u}); 
		cnt[u]++;
		p=((*e[u].rbegin())-cnt[u]*D);
		f[i]=max(p,(*S.rbegin()).first)+h[i];
		q[i+t[i]+1].emplace_back(i);
		e[u].insert(f[i]+cnt[u]*D);val[i]=cnt[u];
		S.insert({(*e[u].rbegin())-cnt[u]*D,u});
	}
	printf("%lld\n",f[n]);
#ifdef LOCAL
    Debug("\nMy Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}
